<div class="row">
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
		<h1 class="page-title txt-color-blueDark"><i class="fa-fw fa fa-group"></i> {:W('Nav/navTop')}
		<span>
            <a class="btn btn-primary" href="#{$Think.config.SUB_PATH}index.php?m=admin&c=role&a=roleadd"><i class="fa fa-plus-circle "></i>&nbsp;&nbsp;{:L('role_add')}</a>
		</span>
		</h1>
	</div>
</div>
	<!-- row -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
						<div class="well no-padding">
<div class="widget-body-toolbar hidden-xs">
						</div>
	<table id='menu_table' class="table table-striped table-hover dataTable text-align-center">
							<thead>
								<tr>
									<th class="text-align-center">ID</th>
									<th class="text-align-center">{:L('role_list_name')}</th>
									<th class="text-align-center hidden-xs">{:L('role_description_tip')}</th>
									<th class="text-align-center"> </th>
								</tr>
							</thead>
							<tbody>	
							</tbody>	
		</table>
	</div>
	</div>
	</div>
<!-- ui-dialog -->
<div id="dialog_simple" title="&nbsp;" >
	<h5 id='log_tip'>
	
	</h5>
</div>
<script src="js/plugin/datatables/jquery.dataTables-cust.min.js"></script>
<script src="js/plugin/datatables/ColReorder.min.js"></script>
<script src="js/plugin/datatables/FixedColumns.min.js"></script>
<script src="js/plugin/datatables/ColVis.min.js"></script>
<script src="js/plugin/datatables/ZeroClipboard.js"></script>
<script src="js/plugin/datatables/media/js/TableTools.min.js"></script>
<script src="js/plugin/datatables/DT_bootstrap.js"></script>
	<script>
	
	function table_list(){
		$.getJSON('{:U("Role/index")}','data=1', function (data) {
		var rs = eval(data.content);
		var table_array = new Array();
		for(var i=0; i<rs.length; i++)
		{
			edit = '<a href="#{$Think.config.SUB_PATH}index.php?m=admin&c=role&a=roleedit&id='+rs[i].role_id+'" title="{:L(\'role_edit\')}"><i class="fa fa-edit fa-lg fa-fw txt-color-blue"></i>{:L(\'role_edit\')}</a> | <a onclick="dialog_del('+rs[i].role_id+')" title="{:L(\'role_delete\')}" href="javascript:void(0);"><i class="glyphicon glyphicon-trash txt-color-red"></i> {:L(\'role_delete\')}</a>|<a href="#{$Think.config.SUB_PATH}index.php?m=admin&c=role&a=rolepriv&id='+rs[i].role_id+'" title="{:L(\'role_permissions\')}"><i class="fa fa-wrench  fa-lg fa-fw txt-color-blue"></i>{:L(\'role_permissions\')}</a> | <a href="#{$Think.config.SUB_PATH}index.php?m=admin&c=user&a=index&role_id='+rs[i].role_id+'" title="{:L(\'role_user\')}"><i class="fa fa-eye  fa-lg fa-fw txt-color-blue"></i>{:L(\'role_user\')}</a>';
			//判断语言
			if( $.cookie('think_language')=="zh-cn" )
			{
				name = rs[i].name;
			}else{
				name = rs[i].en_name;
			}
			table_array.push
			( [
					rs[i].role_id,
					name,
					rs[i].description,
					edit
			]);
		}
		var langage=	
		{                          
			"sZeroRecords": "{:L("sZeroRecords")}",
			"sInfo": "{:L("sInfo")}",
			"sInfoEmtpy": "{:L("sInfoEmtpy")}",
			"sProcessing": "{:L("sProcessing")}",
			"oPaginate": 
			{
				"sFirst": "{:L("sFirst")}",
				"sPrevious": "{:L("sPrevious")}",
				"sNext": "{:L("sNext")}",
				"sLast": "{:L("sLast")}"
			}
		};
		var menu_table = $('#menu_table').dataTable( 
		{
					"sDom" : "<'dt-top-row hidden-xs'Tlf>r<'dt-wrapper't><'dt-row dt-bottom-row'<'row'<'col-sm-6'i><'col-sm-6 text-right'p>>",
					"oTableTools" : 
					{
						"aButtons" : ["copy", "print", 
						              {
										"sExtends" : "collection",
										"sButtonText" : 'Save <span class="caret" />',
										"aButtons" : ["csv", "xls", "pdf"]
									  }
									 ],
						"sSwfPath" : "js/plugin/datatables/media/swf/copy_csv_xls_pdf.swf"
					},
					"aaData": table_array,
					"iDisplayLength": 50,
					"bInfo":true,
					"bFilter":true,
					"bSort":false,
					"bPaginate":true,
					"bLengthChange":true,
					"bProcessing": true,
					"bStateSave":true,
					"bDestroy": true,
					"oLanguage": langage,
					"aoColumns":
					[
					             {"sClass": "text-align-left" },
					             {"stitle": "" },
					             {"sClass": "text-align-left hidden-xs" },
					             {"stitle": ""}
					 ]
					
			        
		}); 
		menu_table.fnAdjustColumnSizing(true);
	});
	}
	table_list();
	var id=''
	function dialog_del(param){
		$('#log_tip').html("{:L(role_delete_tip)}");
		$('#dialog_simple').dialog('open');
		id = param;
		return false;
	}
	$('#dialog_simple').dialog({
		autoOpen : false,
		width : 300,
		resizable : false,
		modal : true,
		title : "",
		buttons : [{
			html : "<i class='fa fa-trash-o'></i>&nbsp; {:L(role_delete)}",
			"class" : "btn btn-danger",
			click : function() {
				$(this).dialog("close");
				$.post('{:U("Role/roleDelete")}','id='+id, function (data) {
						showhidetip(data.msg,2);
				},
				"json"
				);
				
				table_list();return false;
			}
		}, {
			html : "<i class='fa fa-times'></i>&nbsp; {:L(role_cancel)}",
			"class" : "btn btn-default",
			click : function() {
				$(this).dialog("close");
			}
		}]
	});
	</script>
